package com.ptswitch.material.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ptswitch.material.dao.HTreeMapper;
import com.ptswitch.material.model.common.HTree;
import com.ptswitch.material.service.HTreeService;

@Service
public class HTreeServiceImpl implements HTreeService {
    @Autowired
    protected HTreeMapper htreeMapper;

    @Override
    public void init() {
//        InputStream file = HTreeServiceImpl.class.getResourceAsStream("HTreeService.sql");
//        for (String sql : new SqlReader(file).sqls()) {
//            //dao.sqlExecute(sql);
//        }
    }

    @Override
    public List<HTree> findAncestors(String id) {
        return htreeMapper.findAncestors(id);
    }

    @Override
    public List<HTree> findDescendants(String pid) {
        return htreeMapper.findDescendants(pid);
    }

    @Override
    public List<HTree> findParents(String id) {
        return htreeMapper.findParents(id);
    }

    @Override
    public List<HTree> findChildren(String pid) {
        return htreeMapper.findChildren(pid);
    }

    @Override
    public void insert(String id, String pid) {
        htreeMapper.insert(id, pid);
    }

    @Override
    public void delete(String id, boolean deleteAllDescs) {
        htreeMapper.delete(id, deleteAllDescs);
    }

    @Override
    public void move(String id, String npid) {
        htreeMapper.move(id, npid);
    }
}
